.ai-settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.ai-settings-modal {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ai-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
  border-radius: 16px 16px 0 0;
}

.ai-settings-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: #e9ecef;
  color: #333;
}

.ai-settings-content {
  padding: 24px;
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333;
  font-size: 14px;
}

.setting-group label input[type="checkbox"] {
  margin-right: 8px;
}

.preset-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.preset-btn {
  padding: 8px 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  background: white;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.preset-btn:hover {
  border-color: #007bff;
  color: #007bff;
}

.setting-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.setting-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.setting-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.test-btn, .save-btn, .clear-cache-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.test-btn {
  background: #17a2b8;
  color: white;
}

.test-btn:hover:not(:disabled) {
  background: #138496;
}

.test-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.save-btn {
  background: #28a745;
  color: white;
}

.save-btn:hover {
  background: #218838;
}

.clear-cache-btn {
  background: #dc3545;
  color: white;
}

.clear-cache-btn:hover {
  background: #c82333;
}

.test-status {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}

.test-status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.test-status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f1aeb5;
}

.test-status.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.ai-settings-help {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e9ecef;
}

.ai-settings-help details {
  cursor: pointer;
}

.ai-settings-help summary {
  font-weight: 500;
  color: #666;
  font-size: 14px;
  padding: 8px 0;
}

.help-content {
  margin-top: 12px;
  color: #666;
  font-size: 13px;
  line-height: 1.5;
}

.help-content h4 {
  margin: 12px 0 6px 0;
  color: #333;
  font-size: 13px;
}

.help-content ul {
  margin: 6px 0;
  padding-left: 20px;
}

.help-content li {
  margin-bottom: 4px;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .ai-settings-modal {
    width: 95%;
    max-height: 95vh;
    margin: 10px;
    border-radius: 12px;
  }

  .ai-settings-header {
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
  }

  .ai-settings-header h3 {
    font-size: 16px;
  }

  .ai-settings-content {
    padding: 20px;
  }

  .preset-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .setting-actions {
    flex-direction: column;
  }

  .test-btn, .save-btn, .clear-cache-btn {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .ai-settings-overlay {
    padding: 20px;
  }

  .ai-settings-modal {
    width: calc(100% - 40px);
    max-width: 360px;
    max-height: 80vh;
    border-radius: 16px;
    margin: 0 auto;
  }

  .ai-settings-header {
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
  }

  .ai-settings-header h3 {
    font-size: 16px;
  }

  .close-btn {
    font-size: 24px;
    padding: 6px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
  }

  .close-btn:hover {
    background: #fff;
    transform: scale(1.1);
  }

  .ai-settings-content {
    padding: 16px 20px 20px;
  }

  .preset-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .preset-btn {
    padding: 12px;
    font-size: 14px;
    min-height: 44px;
  }

  .setting-input {
    padding: 12px;
    font-size: 16px; /* 防止iOS缩放 */
    min-height: 44px;
    box-sizing: border-box;
  }

  .test-btn, .save-btn, .clear-cache-btn {
    padding: 12px 16px;
    font-size: 15px;
    min-height: 44px;
  }

  .setting-actions {
    gap: 8px;
  }
}